package com.neusoft.elm.service.impl;

import java.util.List;
import com.neusoft.elm.dao.BusinessDao;
import com.neusoft.elm.dao.impl.BusinessDaoImpl;
import com.neusoft.elm.po.Business;
import com.neusoft.elm.service.BusinessService;

public class BusinessServiceImpl implements BusinessService {
    
    @Override
    public List<Business> listAllBusinesses() {
        System.out.println("BusinessServiceImpl.listAllBusinesses() 被调用");
        try {
            BusinessDao dao = new BusinessDaoImpl();
            List<Business> list = dao.listBusiness(null, null);
            System.out.println("DAO层返回的商家列表大小: " + (list != null ? list.size() : 0));
            return list;
        } catch (Exception e) {
            System.err.println("获取商家列表时发生异常: " + e.getMessage());
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public List<Business> listBusinessByOrderTypeId(Integer orderTypeId) {
        System.out.println("BusinessServiceImpl.listBusinessByOrderTypeId() 被调用, orderTypeId: " + orderTypeId);
        try {
            BusinessDao dao = new BusinessDaoImpl();
            List<Business> list = dao.listBusinessByOrderTypeId(orderTypeId);
            System.out.println("DAO层返回的商家列表大小: " + (list != null ? list.size() : 0));
            return list;
        } catch (Exception e) {
            System.err.println("根据订单类型获取商家列表时发生异常: " + e.getMessage());
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public Business getBusinessById(Integer businessId) {
        System.out.println("BusinessServiceImpl.getBusinessById() 被调用, businessId: " + businessId);
        try {
            BusinessDao dao = new BusinessDaoImpl();
            Business business = dao.getBusinessById(businessId);
            System.out.println("DAO层返回的商家信息: " + business);
            return business;
        } catch (Exception e) {
            System.err.println("获取商家信息时发生异常: " + e.getMessage());
            e.printStackTrace();
            return null;
        }
    }
}
